package com.example.malldemo.service.impl;

import com.example.malldemo.common.api.CommonResult;
import com.example.malldemo.component.CancelOrderSender;
import com.example.malldemo.dto.OrderParam;
import com.example.malldemo.service.OmsPortalOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
    public static final Logger LOGGER = LoggerFactory.getLogger(OmsPortalOrderServiceImpl.class);

    @Resource
    private CancelOrderSender cancelOrderSender;

    @Override
    public CommonResult generateOrder(OrderParam orderParam) {
        LOGGER.info("process generateOrder");
        sendDelayMessageCancelOrder(11L);
        return CommonResult.success(null,"下单成功");
    }

    @Override
    public void cancelOrder(Long orderId) {
        LOGGER.info("process cancelOrder orderId:{}",orderId);
    }

    private void sendDelayMessageCancelOrder(Long orderId) {
        long delayTimes = 30 *1000;
        cancelOrderSender.sendMessage(orderId,delayTimes);
    }
}
